<%--
  Created by IntelliJ IDEA.
  User: YCB
  Date: 2019/9/27
  Time: 16:02
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>大鹏-逍遥游</title>
    <link rel="stylesheet" href= "">
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.js"></script>


    <script type="text/javascript" src="${pageContext.request.contextPath}/js/traveldetails.js"></script>

    <link rel="stylesheet" href= "${pageContext.request.contextPath}/css/writetravel.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/modules/layer/default/layer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/dist/css/bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/dist/css/bootstrap-theme.css">
    <script src="${pageContext.request.contextPath}/layui/lay/modules/layer.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/layui/layui.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/activity_release.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/dist/js/bootstrap.js"></script>



    <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/utf8-jsp/lang/zh-cn/zh-cn.js"></script>

    <script src="${pageContext.request.contextPath}/js/qiniuone.js"></script>
    <script src="${pageContext.request.contextPath}/js/qiniutwo.js"></script>

</head>
<body>
<c:choose>
    <c:when test="${memberall.userId != 0}">
        <c:if test="${memberall.userStatus == 0}">
            <img src="http://localhost:8080/mydev/images/vip.png" style="position:absolute;top:23px;right: 345px;z-index: 999;">
        </c:if>
        <c:if test="${memberall.userStatus == 1}">
            <a href="http://localhost:8080/mydev/VIP" style="position:absolute;top:13px;right: 400px;z-index: 999;">开通vip</a>
        </c:if>
    </c:when>
</c:choose>
<div class="header-container" style="width: 100%; min-width: 1500px;  ">

    <div class="row first-div" style="z-index: 999; width: 100%">
        <div class=" left-nav-ul" >
        </div>


        <ul class="mid-nav-ul" >
            <li class="nav-ul-li" >
                <a   style="text-decoration: none" href="http://localhost:8080/mydev/start/index">
                    <div>
                        <img src="http://localhost:8080/mydev/images/logo.png">
                        逍遥游
                    </div>
                </a>

            </li>
            <li class="nav-ul-li" style="background-color: #ff9d00">
                <a style="text-decoration: none;color: #ffffff" href="http://localhost:8080/mydev/start/index">首页</a>
            </li>
            <li class="nav-ul-li">
                <a  style="text-decoration: none" href="http://localhost:8080/mydev/QuestionTable/club_questions">问答</a>
            </li>

            <li class="nav-ul-li">
                <a   style="text-decoration: none" href="http://localhost:8080/mydev/clublist/list">鲲鹏俱乐部</a>
            </li>

            <li class="nav-ul-li new">
                <div class="geren">
                    <a  style="text-decoration: none; color:black" href="">更多</a>
                    <div class="t1"></div>
                </div>
                <div class="hidden1">
                    <ul class="geren-ul">
                        <li>
                            <a  style="text-decoration: none" href="http://localhost:8080/mydev/write/travel">写游记</a>
                        </li>
                        <li>
                            <a  style="text-decoration: none"  href="http://localhost:8080/mydev/myhome/mytravel/${memberall.userId}">我的游记</a>
                        </li>
                    </ul>
                </div>
            </li>

            <li class="nav-ul-li" >
                <c:choose>
                    <c:when test="${memberall.userId != 0}">
                        <c:if test="${memberall.userStatus ==0}">
                             <span  style="color: gold">
                                 欢迎!${memberall.userName}
                             </span>
                        </c:if>
                        <c:if test="${memberall.userStatus ==1}">
                             <span  style="color: black">
                                 欢迎!${memberall.userName}
                             </span>
                        </c:if>


                    </c:when>
                    <c:otherwise>
                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/regist/normalRegist">注册</a>
                    </c:otherwise>
                </c:choose>

            </li>
            <li class="nav-ul-li">
                <c:choose>
                    <c:when test="${memberall.userId != 0}">

                    </c:when>
                    <c:otherwise>
                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/login/login">登陆</a>
                    </c:otherwise>
                </c:choose>


            </li>
        </ul>




        <c:choose>
            <c:when test="${memberall.userId != 0}">

                <div class="right-nav-ul" >
                    <div class="topmaguser" style="  position:relative;left: 0px;top:2px">


                        <a href="http://localhost:8080/mydev/myhome/mytravel/${memberall.userId}" >
                            <img src="http://localhost:8080/mydev/${memberall.userPicture}">
                        </a>

                    </div>
                    <ul class="right-mid" >
                        <li class="nav-ul-li new" >

                            <div class="geren">

                                <a style="text-decoration: none; color:black" href="">个人中心</a>

                                <div class="t2"></div>
                            </div>

                            <div class="hidden1">
                                <ul class="gere-ul">

                                    <li style="height: 45px;">
                                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/myfoot/collect/${memberall.userId}"><img src="http://localhost:8080/mydev/images/savea.png">我的收藏</a>
                                    </li>
                                    <li style="height: 45px;">
                                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/myfoot/mapview/${memberall.userId}"><img src="http://localhost:8080/mydev/images/foot.png">我的足迹</a>
                                    </li>
                                    <li style="height: 45px;">
                                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/myfoot/answer/${memberall.userId}"><img src="http://localhost:8080/mydev/images/question.png">我的问答</a>
                                    </li>
                                    <li style="height: 45px;">
                                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/reply/toaccount/${memberall.userId}"><img src="http://localhost:8080/mydev/images/question.png">回复消息</a>
                                    </li>

                                    <li style="height: 45px;">
                                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/exit"><img src="http://localhost:8080/mydev/images/banka.png">退出登录</a>
                                    </li>
                                </ul>
                            </div>
                        </li>
                    </ul>
                </div>
            </c:when>
            <c:otherwise>



            </c:otherwise>
        </c:choose>

    </div>
</div>

<div class="main">
    <div class="main-top" style="background-image:url(${pageContext.request.contextPath}/images/a30963ba09c88ba018d4af94edf9cd5c.jpg.png);background-size:1500px 500px">
        <div id="travelpic" class="traveltoppic">

        </div>

        <button style=" position:absolute; top:570px;left:30px;height: 38px;width: 115px;background-color: #ff9d00" class="layui-btn">
            <i class="layui-icon">&#xe67c;</i>上传头图</button>

        <form method="post" enctype="multipart/form-data" id="imgform" style=" position:absolute; top:570px;left:30px;height: 38px;opacity:0">
            <input type="file" name="myfile" id="myfile" style="height: 38px;width: 115px;opacity:0">
        </form>
        <script>
            $("#myfile").change(function () {
                $("#imgform").ajaxSubmit({
                    url:"${pageContext.request.contextPath}/test/upload",
                    method:"POST",
                    dataType:"json",
                    success:function (data) {
                        console.log(data.imgUrl);
                        var ele ="<img>"
                        $("#travelpic").empty();
                        $("#travelpic").append(ele);
                        $("#travelpic").find("img").attr("src",data.imgUrl);
                    }
                    ,error:function (data) {
                        alert(data)
                    }
                })
            })
        </script>
        <div class="input-text">
            <input type="text" placeholder="填写标题游记" id="traveltitel">
        </div>



    </div>
</div>


<div class="ask_wp" style="width: 1000px;margin:20px auto">
    <!--  ====================================body主体===================================== -->
    <!--左边-->
    <div style="width: 675px;margin-bottom: 30px;float: left">
        <div class="ask_item mt10" style="position: relative;">

            <form id="js_add_question" _action="/question.php?action=doadd&amp;id=" method="post" style="">
                <!--日期时间设置-->
                <div class="time-setting" style="margin-top: 50px;">
                    <div class="layui-form">
                        <div class="layui-form-item">
                            <!--出发日期-->
                            <div class="layui-inline">
                                <label class="layui-form-label" style="width: 90px;" id="traveldate">出发日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="test-limit1" placeholder="yyyy-MM-dd">
                                </div>
                            </div>

                        </div>


                    </div>
                    <script>
                        layui.use('laydate', function(){
                            var laydate = layui.laydate;
                            //限定可选日期
                            var ins22 = laydate.render({
                                elem: '#test-limit1'
                                ,theme: '#ffa800'
                                ,min:-100
                                ,max:90
                            });
                            //限定可选时间
                            laydate.render({
                                elem: '#test-limit3'
                                ,theme: '#ffa800'
                                ,type: 'time'
                                ,btns: ['clear', 'confirm']
                            });
                            laydate.render({
                                elem: '#test10'
                                ,type: 'datetime'
                                ,range: true
                                ,theme: '#ffa800'
                                ,min: 0
                                ,max:30
                            });
                        });
                    </script>
                </div>
                <!--发布费用-->
                <div class="layui-form-item" >
                    <div class="layui-inline" style="margin-left: -10px">
                        <label class="layui-form-label" style="width: 100px;">人均费用</label>

                        <div class="layui-input-inline" style="width: 100px;">
                            <input  type="text" id="peoplemoeny" name="price_min" placeholder="￥" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>

                <!--出行天数-->
                <div class="layui-form-item" >
                    <div class="layui-inline" style="margin-left: -10px">
                        <label class="layui-form-label" style="width: 100px;">出行天数</label>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input  type="text" id="gooutday" name="price_min"  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>

                <!--人物关系-->
                <div class="layui-form-item" >
                    <div class="layui-inline" style="margin-left: -10px">
                        <label class="layui-form-label" style="width: 100px;">人物关系</label>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input  type="text" id="person" name="price_min"  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <!--出游地区-->
                <div style="height: 40px;width: 500px;">
                    <div class="" style="margin-left: -10px">
                        <label class="layui-form-label" style="width: 100px;">出游地区</label>

                        <div class="three-area">
                            <select id="cmbProvince" name="cmbProvince"></select>
                            <select id="cmbCity" name="cmbCity"></select>
                            <select id="cmbArea" name="cmbArea"></select>
                            <script type="text/javascript">
                                addressInit('cmbProvince', 'cmbCity', 'cmbArea');
                            </script>

                        </div>
                    </div>
                </div>



                <!--文本域-->
                <div class="text-area">
                    <div style="margin-top:50px;">
                        <span><strong style="font-size: 20px;color: #636363">主体内容</strong></span>
                    </div>
                    <div>

               <%--         /***************************富文本***********************/--%>
                        <textarea id="demo" style="display: none;"></textarea>
                       <%-- <div class="site-demo-button" style="margin-top: 20px;">
                            <button class="layui-btn site-demo-layedit" data-type="content">获取编辑器内容</button>
                            <button class="layui-btn site-demo-layedit" data-type="text">获取编辑器纯文本内容</button>
                            <button class="layui-btn site-demo-layedit" data-type="selection">获取编辑器选中内容</button>
                        </div>--%>
                        <script src="${pageContext.request.contextPath}/layui/layui.js" charset="utf-8"></script>

                    </div>


                </div>





                <!--提交 .layui-layer-btn .layui-layer-btn0 -->
                <div class="site-demo-button" id="layerDemo" style="float:right;margin-bottom: 0;margin-top: 50px">
                    <button data-method="notice" class="layui-btn" id="tijiao" onclick="tijiaoxx()" type="button" style="background-color: #ff9d00">去发布吧</button>
                </div>




            </form>
        </div>
    </div>

</div>

<script>
    var layedit
    var active;
    var index;

    layui.use('layedit', function(){
         layedit = layui.layedit;
        layedit.set({
            uploadImage:{
                url:'${pageContext.request.contextPath}/uploadFile',
                type:'post',

            }

        });
         index = layedit.build('demo',{
             tool: ['strong', 'italic', 'underline', '|', 'left', 'center', 'right','image','link']
             ,height: 500,width:400
         }); //建立编辑器


        active = {
            content: function(){
                alert(layedit.getContent(index)); //获取编辑器内容
            }
            ,text: function(){
                alert(layedit.getText(index)); //获取编辑器纯文本内容
            }
            ,selection: function(){
                alert(layedit.getSelection(index));
            }
        };
        $('.site-demo-layedit').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

    function tijiaoxx() {
        var traveltitel = $("#traveltitel").val();//标题
        var traveldate = $("#test-limit1").val();//出行日期
        var peoplemoeny = $("#peoplemoeny").val();//人均费用
        var gooutday= $("#gooutday").val();//出行天数
        var person=$("#person").val();//人物关系
        var cmbProvince=$("#cmbProvince").val();//省份
        var cmbCity=$("#cmbCity").val();//市级
        var cmbArea=$("#cmbArea").val();//县级
        var img = $("#travelpic img").attr('src');//获取头图路径
        var textall = layedit.getContent(index);//获取带标签的全部富文本数据
        var textTT = layedit.getText(index);//获取富文本纯文本数据
        var textes = textTT.substring(0,86);//获取富文本前86个数据用来渲染首页的游记列表



     if(parseInt(gooutday)!=gooutday){
          alert("请输入正确的出行天数哦》》");
          return false;
      }else if(traveltitel == ""){
           alert("请输入标题");
            return false;
        }else if(cmbProvince == "请选择省份"){
            alert("请选择省份");
            return false;
        }else if(textTT.length<100){
            alert("游记至少100个字符哦 ( ‘-ωก̀ )");
            return false;
        }else{
         $.ajax({
             type:"POST",
             data:"traveltitel="+traveltitel+"&traveldate="+traveldate+"&peoplemoeny="+peoplemoeny+"&gooutday="+gooutday+"&person="+person+"&cmbProvince="+cmbProvince+"&cmbCity="+cmbCity+"&cmbArea="+cmbArea+"&img="+img+"&textall="+textall+"&textsx="+textes,
             datatype:"json",
             url:"${pageContext.request.contextPath}/write/travelnote",
             success:function (result){
                 window.location.href="${pageContext.request.contextPath}/start/index"
             },
             error:function (result) {
                 window.location.href="${pageContext.request.contextPath}/start/index"

             }
         })

     }

    }

</script>
</body>
</html>
